//
//  MKHomePageViewController.m
//  ManKeCartoon
//
//  Created by dllo on 15/10/15.
//  Copyright © 2015年 ManKe. All rights reserved.
//

#import "MKHomePageViewController.h"
#import "MKBaseHeader.h"
#import "MKLineComicViewController.h"
@interface MKHomePageViewController ()<UITableViewDataSource, UITableViewDelegate, UICollectionViewDataSource, UICollectionViewDelegate>
@property (nonatomic, strong) MKScrollLB *scroll;

@property (nonatomic, strong) UICollectionView *rollPlayImage; // 轮播图

@property (nonatomic, assign) NSInteger count;

@property (nonatomic, strong) UIPageControl *pageControl;

@property (nonatomic, retain) NSTimer *myTimer;

@end

@implementation MKHomePageViewController
- (void)viewWillAppear:(BOOL)animated{

    self.tabBarController.tabBar.hidden = NO;
}


- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    [[DataBase shareDataBase] openDB];
    [[DataBase shareDataBase] createTable];
    [self.view setBackgroundColor:[UIColor whiteColor]];
    

    
//    [AFNETWORK getDataWithNoCacheString:@"http://mobilev3.ac.qq.com/Home/homePageDetailV2/timestamp/0/user_local_version/5.0.7/user_channel/2011/" block:^(id block) {

        [AFNETWORK getDataWithString:@"http://mobilev3.ac.qq.com/Home/homePageDetailV2/timestamp/0/user_local_version/5.0.7/user_channel/2011/" block:^(id block) {
            
            self.scMutableArray = [[NSMutableArray alloc] init];
            self.crMutableArray = [[NSMutableArray alloc] init];
            self.mfMutableArray = [[NSMutableArray alloc] init];
            self.gxMutableArray = [[NSMutableArray alloc] init];
            self.rmMutableArray = [[NSMutableArray alloc] init];
            self.xzMutableArray = [[NSMutableArray alloc] init];
            self.topMutableArray = [[NSMutableArray alloc] init];
            self.myMUtableArray = [[NSMutableArray alloc] init];
            self.bigMUtableArray = [[NSMutableArray alloc] init];

        for (NSDictionary *dic in [[[block objectForKey:@"data"] objectForKey:@"banner"] objectForKey:@"data"]) {
            MKHomeScModel *home = [[MKHomeScModel alloc] initWithDictionary:dic];
            [self.scMutableArray addObject:home];
        }
        
        for (NSDictionary *dic in [[[block objectForKey:@"data"] objectForKey:@"comicList1"] objectForKey:@"data"]) {
            MKFirstModel *model = [[MKFirstModel alloc] initWithDictionary:dic];
            [self.crMutableArray addObject:model];
        }
            
        for (NSDictionary *dic in [[[block objectForKey:@"data"] objectForKey:@"comicList2"] objectForKey:@"data"]) {
            MKFirstModel *model = [[MKFirstModel alloc] initWithDictionary:dic];
            [self.mfMutableArray addObject:model];
        }
            
        for (NSDictionary *dic in [[[block objectForKey:@"data"] objectForKey:@"comicList3"] objectForKey:@"data"]) {
            MKFirstModel *model = [[MKFirstModel alloc] initWithDictionary:dic];
            [self.gxMutableArray addObject:model];
        }
            
        for (NSDictionary *dic in [[[block objectForKey:@"data"] objectForKey:@"comicList4"] objectForKey:@"data"]) {
            MKFirstModel *model = [[MKFirstModel alloc] initWithDictionary:dic];
            [self.rmMutableArray addObject:model];
        }
            
        for (NSDictionary *dic in [[[block objectForKey:@"data"] objectForKey:@"comicList5"] objectForKey:@"data"]) {
            MKFirstModel *model = [[MKFirstModel alloc] initWithDictionary:dic];
            [self.xzMutableArray addObject:model];
        }
            
        for (NSDictionary *dic in [[[block objectForKey:@"data"] objectForKey:@"top"] objectForKey:@"data"]) {
            MKFirstModel *model = [[MKFirstModel alloc] initWithDictionary:dic];
            [self.topMutableArray addObject:model];
        }
        
        // 把获取到的所有数据都放入一个数组里面
        [self.bigMUtableArray addObjectsFromArray:self.crMutableArray];
        [self.bigMUtableArray addObjectsFromArray:self.mfMutableArray];
        [self.bigMUtableArray addObjectsFromArray:self.gxMutableArray];
        [self.bigMUtableArray addObjectsFromArray:self.rmMutableArray];
        [self.bigMUtableArray addObjectsFromArray:self.xzMutableArray];
        [self.bigMUtableArray addObjectsFromArray:self.topMutableArray];
        
        // 把获取到的所有数据都放入一个数组里面
        [self.myMUtableArray addObject:self.crMutableArray];
        [self.myMUtableArray addObject:self.mfMutableArray];
        [self.myMUtableArray addObject:self.gxMutableArray];
        [self.myMUtableArray addObject:self.rmMutableArray];
        [self.myMUtableArray addObject:self.xzMutableArray];
        [self.myMUtableArray addObject:self.topMutableArray];


            if (_tableView == nil) {
                
                [self createScrollView];
                [self createTableView];
                
            } else {
                
                [_tableView reloadData];
                
            }
            
    }];
    
}



#pragma mark - 引入 轮播图 & 首页四个button
-(void)createScrollView
{

    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
    flowLayout.itemSize = CGSizeMake(SCREEN_WIDTH, SCREEN_HEIGHT / 3);
    flowLayout.minimumInteritemSpacing = 0;
    flowLayout.minimumLineSpacing = 0;
    flowLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;
    
    _rollPlayImage = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT / 3) collectionViewLayout:flowLayout];
    _rollPlayImage.dataSource = self;
    _rollPlayImage.delegate = self;
    _rollPlayImage.pagingEnabled = YES;
    
    NSIndexPath *indexPath = [NSIndexPath indexPathForItem:0 inSection:100];
    
    [_rollPlayImage scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionNone animated:NO];
    
    [_rollPlayImage registerClass:[MKRollPlayImageCollectionViewCell class] forCellWithReuseIdentifier:@"reuseIdentifier"];
    
    _rollPlayImage.showsHorizontalScrollIndicator = NO;
    
    self.myTimer = [NSTimer scheduledTimerWithTimeInterval:3 target:self selector:@selector(timerClick) userInfo:nil repeats:YES];
    
//    self.scroll = [[MKScrollLB alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT/3)];
//
//
//    //[self.view addSubview:_scroll];
//
//
//    // 为scrolview所在view添加点击事件
//    UITapGestureRecognizer *sin = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(scrollClick)];
//    sin.numberOfTapsRequired = 1;
//    sin.numberOfTouchesRequired = 1;
//    [self.scroll addGestureRecognizer:sin];
//    
    self.headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT/2)];
    //[self.headerView setBackgroundColor:[UIColor greenColor]];
    //[self.view addSubview:self.headerView];
    [self.headerView addSubview:_rollPlayImage];
    
    
    // 添加封装好的4个button
    self.opView = [[MKOPView alloc] initWithFrame:CGRectMake(0, SCREEN_HEIGHT/3, SCREEN_WIDTH, SCREEN_HEIGHT/2-SCREEN_HEIGHT/3)];
    // 添加OPViewbutton的点击事件
    for (int i = 0; i < 4; i++) {
        UIButton *OPbu1 = (UIButton *)[self.opView viewWithTag:300 + i];
        [OPbu1 addTarget:self action:@selector(categoryClick:) forControlEvents:UIControlEventTouchUpInside];
    }
    [self.headerView addSubview:self.opView];
    //[self.opView setBackgroundColor:[UIColor redColor]];
    
}
#pragma mark - 四个Button的点击方法
- (void)categoryClick:(UIButton *)sender{
    
    switch (sender.tag) {
        case 300:
        {
            MKVideoViewController *video = [[MKVideoViewController alloc]init];
            [self.navigationController pushViewController:video animated:YES];
        }
            break;
        case 301:
        {
            MKSearchViewController *searchViewController = [[MKSearchViewController alloc] init];
            searchViewController.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:searchViewController animated:YES];
        }
            break;
        case 302:
        {
            MKUpDateViewController *update = [[MKUpDateViewController alloc] init];
            [self.navigationController pushViewController:update animated:YES];
        }
            break;
        case 303:
        {
            MKLineComicViewController *lineComic = [[MKLineComicViewController alloc] init];
            [self.navigationController pushViewController:lineComic animated:YES];
        }
            break;
        default:
            break;
    }
    
//    NSLog(@"%ld", sender.tag);
}
#pragma mark - CollectionView DataSource&Delegate
- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
    return _scMutableArray.count;
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
    return 1000;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
    MKRollPlayImageCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"reuseIdentifier" forIndexPath:indexPath];
    MKHomeScModel *scModel = [_scMutableArray objectAtIndex:indexPath.row];
    [cell setSCrollModel:scModel];
    cell.backgroundColor = [UIColor whiteColor];
    return cell;
}
#pragma mark - 轮播图点击方法
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath
{
    MKCartoonViewController *cartoon = [[MKCartoonViewController alloc] init];
    MKLineComicBrowseViewController *lineComic = [[MKLineComicBrowseViewController alloc] init];
    MKHomeScModel *model = [_scMutableArray objectAtIndex:indexPath.row];
    if ([model.special_event_url isEqualToString:@""]) {
        cartoon.comic_id = model.comic_id.stringValue;
        [self.navigationController pushViewController:cartoon animated:YES];
    }
    else
    {
        lineComic.url = model.special_event_url;
        [self.navigationController pushViewController:lineComic animated:YES];
    }
}
#pragma mark - ScrollView 轮播图滑动方法
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    if (scrollView == _rollPlayImage) {
        _count = (NSInteger)(_rollPlayImage.contentOffset.x / SCREEN_WIDTH - _scMutableArray.count * 10);
        [_pageControl setCurrentPage:_count % _scMutableArray.count];
        //        [_myTimer setFireDate:[NSDate date]];
    }
}
#pragma mark - Time
- (void)timerClick
{
    [_rollPlayImage setContentOffset:CGPointMake(SCREEN_WIDTH * _scMutableArray.count * 10 + SCREEN_WIDTH * _count, 0) animated:YES];
    _count ++;
}
#pragma mark - PageControl
- (void)setUpPageControl
{
    _pageControl = [[UIPageControl alloc] initWithFrame:CGRectMake(-SCREEN_WIDTH / 2, SCREEN_HEIGHT / 3 + 10, SCREEN_WIDTH, 10)];
    // 设置一共有几个(几个小圆点)
    [_pageControl setNumberOfPages:_scMutableArray.count];
    // 未选中的颜色
    [_pageControl setPageIndicatorTintColor:[UIColor lightGrayColor]];
    // 选中的颜色
    [_pageControl setCurrentPageIndicatorTintColor:[UIColor whiteColor]];
    // 设置当前页
    [_pageControl setCurrentPage:0];
    
    [_rollPlayImage addSubview:_pageControl];
}
#pragma mark - 创建TableView
- (void)createTableView{
    
    self.tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 64, SCREEN_WIDTH, SCREEN_HEIGHT-90) style:UITableViewStyleGrouped];
    
    [self.tableView setBackgroundColor:[UIColor whiteColor]];
    
    [self.tableView setTableHeaderView:self.headerView];
    [self.view addSubview:self.tableView];
    [self.tableView setDataSource:self];
    [self.tableView setDelegate:self];
    self.tableView.allowsSelection = NO;
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
}

-(void)scrollClick
{
    
    int i = self.scroll.LBScrollView.contentOffset.x / SCREEN_WIDTH;
    NSString *strComic;
    if (i == 0) {
        strComic = [[self.scMutableArray lastObject] comic_id];
    }else if(i == self.scMutableArray.count + 1){
        strComic = [[self.scMutableArray firstObject] comic_id];
    }else {
        strComic = [self.scMutableArray[i - 1] comic_id];
    }
    MKCartoonViewController *cartoon = [[MKCartoonViewController alloc] init];
    if(strComic != nil){
        cartoon.comic_id = strComic;
        cartoon.hidesBottomBarWhenPushed = YES;
        [self.navigationController pushViewController:cartoon animated:NO];
    }
    


}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    return 6;
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    if (section == 5) {
        return 5;
    }
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0) {
    
        static NSString *firstCellID = @"firstCell";
        MKFirstTableViewCell *firstCell = [tableView dequeueReusableCellWithIdentifier:firstCellID];
        
        if (firstCell == nil) {
            
            firstCell = [[MKFirstTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:firstCellID BigArray:self.myMUtableArray index:indexPath.section];
            
        }

        for (int i = 0; i < [self.myMUtableArray[0] count]; i++) {
            
            UIButton *button = (UIButton *)[firstCell viewWithTag:100+i];
            [button addTarget:self action:@selector(cellButtonClick:) forControlEvents:UIControlEventTouchUpInside];
            
        }

        return firstCell;
        
    } else if (indexPath.section == 2) {
        
        static NSString *firstCellPlusID = @"firstCellPlus";
        MKFirstTableViewCell *firstCellPlus = [tableView dequeueReusableCellWithIdentifier:firstCellPlusID];
        if (firstCellPlus == nil) {
            firstCellPlus = [[MKFirstTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:firstCellPlusID BigArray:self.myMUtableArray index:indexPath.section];
        }
        
        
        for (int i = 0; i < [self.myMUtableArray[2] count]; i++) {
            
            UIButton *button = (UIButton *)[firstCellPlus viewWithTag:100+i+[self.myMUtableArray[0] count]+[self.myMUtableArray[1] count]];
            [button addTarget:self action:@selector(cellButtonClick:) forControlEvents:UIControlEventTouchUpInside];
            
        }
        
        
        
        return firstCellPlus;
        

        
    } else if (indexPath.section == 5) {
        
        static NSString *thirdCellID = @"thirdCell";
        MKThirdTableViewCell *thirdCell = [tableView dequeueReusableCellWithIdentifier:thirdCellID];
        if (thirdCell == nil) {
            thirdCell = [[MKThirdTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:thirdCellID];
        }
        
        if (self.myMUtableArray.count != 0) {
            
        [thirdCell getDataWithModel:[self.myMUtableArray[indexPath.section]objectAtIndex:indexPath.row]];
            
        }
        [thirdCell.numLabel setText:[NSString stringWithFormat:@"0%ld",indexPath.row + 1]];
        if (indexPath.row == 0) {
            [thirdCell.numLabel setTextColor:[UIColor redColor]];
        }else if (indexPath.row == 1){
            [thirdCell.numLabel setTextColor:[UIColor orangeColor]];
        }else if (indexPath.row == 2){
            [thirdCell.numLabel setTextColor:[UIColor blueColor]];
        }else if (indexPath.row == 3){
            [thirdCell.numLabel setTextColor:[UIColor grayColor]];
        }else if (indexPath.row == 4){
            [thirdCell.numLabel setTextColor:[UIColor grayColor]];
        }
        thirdCell.topButton.tag = 100 + indexPath.row + [self.myMUtableArray[0] count] + [self.myMUtableArray[1] count] + [self.myMUtableArray[2] count] + [self.myMUtableArray[3] count] + [self.myMUtableArray[4] count];
        [thirdCell.topButton addTarget:self action:@selector(cellButtonClick:) forControlEvents:UIControlEventTouchUpInside];

        
        return thirdCell;
   
    } else {

        
        
        static NSString *secondCellID = @"secondCell";
        MKSecondTableViewCell *secondCell = [tableView dequeueReusableCellWithIdentifier:secondCellID];
        if (secondCell == nil) {
            secondCell = [[MKSecondTableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:secondCellID];
        }
        
        if (indexPath.section == 1) {
            

            [secondCell.leftButton setTag:100+[self.myMUtableArray[0] count] ];
            [secondCell.midButton setTag:101+[self.myMUtableArray[0] count] ];
            [secondCell.rightButton setTag:102+[self.myMUtableArray[0] count] ];
            
        } else if (indexPath.section == 3) {
            

            [secondCell.leftButton setTag:100+[self.myMUtableArray[0] count] +[self.myMUtableArray[1]count]+[self.myMUtableArray[2]count]];
            [secondCell.midButton setTag:101+[self.myMUtableArray[0] count] +[self.myMUtableArray[1]count]+[self.myMUtableArray[2]count]];
            [secondCell.rightButton setTag:102+[self.myMUtableArray[0] count] +[self.myMUtableArray[1]count]+[self.myMUtableArray[2]count]];

            
        } else if (indexPath.section == 4) {
            

            
            [secondCell.leftButton setTag:100+[self.myMUtableArray[0] count] +[self.myMUtableArray[1]count]+[self.myMUtableArray[2]count]+[self.myMUtableArray[3]count]];
            [secondCell.midButton setTag:101+[self.myMUtableArray[0] count] +[self.myMUtableArray[1]count]+[self.myMUtableArray[2]count]+[self.myMUtableArray[3]count]];
            [secondCell.rightButton setTag:102+[self.myMUtableArray[0] count] +[self.myMUtableArray[1]count]+[self.myMUtableArray[2]count]+[self.myMUtableArray[3]count]];

            
        }
        
        [secondCell getDataWithModel:self.myMUtableArray[indexPath.section]];
        [secondCell.leftButton addTarget:self action:@selector(cellButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        [secondCell.midButton addTarget:self action:@selector(cellButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        [secondCell.rightButton addTarget:self action:@selector(cellButtonClick:) forControlEvents:UIControlEventTouchUpInside];
        
        return secondCell;

        
    }

}
- (void)cellButtonClick:(UIButton *)sender{
    
    MKCartoonViewController *cartoon = [[MKCartoonViewController alloc] init];
    cartoon.comic_id = [self.bigMUtableArray[sender.tag - 100] comic_id];
    
    cartoon.hidesBottomBarWhenPushed = YES;
    
    [self.navigationController pushViewController:cartoon animated:YES];
    
}


- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (indexPath.section == 0 || indexPath.section == 2) {
        
        return SCREEN_HEIGHT/2+60;
        
    } else if (indexPath.section == 5) {
        
        return SCREEN_HEIGHT/7;
        
    } else {
        
        return SCREEN_HEIGHT/3-20;
        
    }

}
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    NSArray *titleImageArray = @[@"CRQZP.png", @"JTWMF.png", @"JTWGX.png", @"RMSZKZL.png", @"XZSSSSD.png"];

    if (section == 5) {
        UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT/16)];
        UILabel *topFive = [[UILabel alloc] initWithFrame:CGRectMake(10,5, SCREEN_WIDTH / 4, 25)];
        [topFive setTextColor:[UIColor whiteColor]];
        [topFive setText:@"今日TOP5"];
        [topFive setTextAlignment:NSTextAlignmentCenter];
        [topFive setFont:[UIFont boldSystemFontOfSize:15]];
        [topFive setBackgroundColor:[UIColor colorWithRed:.95 green:0.1 blue:0.1 alpha:1]];
        [headerView addSubview:topFive];
        
        UIView *topLine = [[UIView alloc] initWithFrame:CGRectMake(10 + topFive.frame.size.width / 2 - 2, topFive.frame.size.height + topFive.frame.origin.y, 4, 12)];
        [topLine setBackgroundColor:[UIColor colorWithRed:.95 green:0.1 blue:0.1 alpha:1]];
        [headerView addSubview:topLine];
        
        UILabel *smileLabel = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 60, topFive.frame.origin.y + topFive.frame.size.height / 2, 60, 20)];
        [smileLabel setTextAlignment:NSTextAlignmentCenter];
        [smileLabel setTextColor:[UIColor redColor]];
        [smileLabel setText:@"(o^.^o)"];
        [smileLabel setFont:[UIFont boldSystemFontOfSize:15]];
        [headerView addSubview:smileLabel];
        return headerView;
        
    } else {
        
        UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT/8)];
        
        //[headerView setBackgroundColor:[UIColor redColor]];
        
        
        
        UIButton *titleButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [titleButton setFrame:CGRectMake(SCREEN_WIDTH / 5, 0, SCREEN_HEIGHT / 3, SCREEN_HEIGHT / 8)];
        [titleButton setImage:[UIImage imageNamed:titleImageArray[section]] forState:UIControlStateNormal];
        [titleButton addTarget:self action:@selector(titleClick:) forControlEvents:UIControlEventTouchUpInside];
        [titleButton setTag:section];
        [headerView addSubview:titleButton];
        
        UIView *leftLine = [[UIView alloc] initWithFrame:CGRectMake(7, titleButton.frame.size.height / 2, SCREEN_WIDTH / 5, .5)];
        [leftLine setBackgroundColor:[UIColor grayColor]];
        [headerView addSubview:leftLine];
        UIView *rightLine = [[UIView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 7 - SCREEN_WIDTH / 5 , titleButton.frame.size.height / 2, SCREEN_WIDTH / 5, .5)];
        [rightLine setBackgroundColor:[UIColor grayColor]];
        [headerView addSubview:rightLine];
        

        return headerView;
    }

  
}
- (void)titleClick:(UIButton *)sender{
    
    NSArray *classifyIdArray = @[@"http://mobilev3.ac.qq.com/Home/homeComicListMore/category_id/50005/user_local_version/5.0.7/user_channel/2011/", @"http://mobilev3.ac.qq.com/Home/homeComicListMore/category_id/99999/user_local_version/5.0.7/user_channel/2011/", @"http://mobilev3.ac.qq.com/Home/homeComicListMore/category_id/88888/user_local_version/5.0.7/user_channel/2011/", @"http://mobilev3.ac.qq.com/Home/homeComicListMore/category_id/40004/user_local_version/5.0.7/user_channel/2011/", @"http://mobilev3.ac.qq.com/Home/homeComicListMore/category_id/77777/user_local_version/5.0.7/user_channel/2011/"];
    NSArray *titleNameArray = @[@"超人气作品", @"今天我免费", @"今天我更新", @"日漫神作看这里", @"新作上升嗖嗖的"];
    
    MKPersonViewController *per = [[MKPersonViewController alloc] init];
    per.classify_id = classifyIdArray[sender.tag];
    per.titleName = titleNameArray[sender.tag];
    per.titleName = titleNameArray[sender.tag];
    per.hidesBottomBarWhenPushed = YES;
    [self.navigationController pushViewController:per animated:YES];

    
}


- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    
    return 0.00001;
    
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    if (section == 5) {
        
        return SCREEN_HEIGHT/16;
        
    } else {
        
        return SCREEN_HEIGHT/8;
        
    }
    
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
